﻿app.directive('onBlur', function () {
    return {
        restrict: 'A',
        link: function (scope, elm, attrs) {
            elm.bind('blur', function () {
                scope.$apply(attrs.onBlur);
            });
        }
    };
});

app.directive('onEnter', function () {
    return function (scope, element, attrs) {
        element.bind('keydown keypress', function (event) {
            if (event.which === 13) {
                scope.$apply(function () {
                    scope.$eval(attrs.onEnter);
                });

                event.preventDefault();
            }
        });
    };
});